﻿using System;

class DecimalToHexadecimal
{
    static void Main()
    {
        int deciNum = 1023;
        string hexNum = ConvertDecimalToHex(deciNum);

        Console.WriteLine("Decimal:     " + deciNum);
        Console.WriteLine("Hexadecimal: " + hexNum);
    }

    private static string ConvertDecimalToHex(int number)
    {
        string hexNum = String.Empty;
        int remainder = 0;
        int numBase = 16;

        do
        {
            remainder = number % numBase;
            hexNum = GetHexSymbol(remainder) + hexNum;
            number = number / numBase;
        }
        while (number != 0);

        return hexNum;
    }

    private static string GetHexSymbol(int deciNum)
    {
        string hexSymbol = String.Empty;

        switch (deciNum)
        {
            case 10:
                hexSymbol = "A";
                break;
            case 11:
                hexSymbol = "B";
                break;
            case 12:
                hexSymbol = "C";
                break;
            case 13:
                hexSymbol = "D";
                break;
            case 14:
                hexSymbol = "E";
                break;
            case 15:
                hexSymbol = "F";
                break;
            default:
                hexSymbol = deciNum.ToString();
                break;
        }

        return hexSymbol;
    }
}
